package cs342.uwosh.group1.mycontacts.Threads;

import java.util.ArrayList;
import java.util.List;


import cs342.uwosh.group1.mycontacts.Category;
import cs342.uwosh.group1.mycontacts.MainActivity;
import cs342.uwosh.group1.mycontacts.SqlConnect;



import android.os.AsyncTask;
import android.os.Bundle;
import android.widget.TextView;

public class GetAllCategoryNamesTask extends AsyncTask<Object, Object, List<Category>>
{

	@Override
	protected List<Category> doInBackground(Object... arg0)
	{
		SqlConnect db = MainActivity.db;
		return db.getAllCategories();
	}
	
	protected void onPostExecute(List<Category> result)
	{	
		if(MainActivity.db.categoryCount() > 0)
		{
			MainActivity.catOneView.setText(result.get(0).getCategoryName());
		}
		else
		{
			MainActivity.catOneView.setText("New Category");
		}
		
		if(MainActivity.db.categoryCount() > 1)
		{
			MainActivity.catTwoView.setText(result.get(1).getCategoryName());
		}
		else
		{
			MainActivity.catTwoView.setText("New Category");
		}
		
		if(MainActivity.db.categoryCount() > 2)
		{
			MainActivity.catThreeView.setText(result.get(2).getCategoryName());
		}
		else
		{
			MainActivity.catThreeView.setText("New Category");
		}
		
		if(MainActivity.db.categoryCount() > 3)
		{
			MainActivity.catFourView.setText(result.get(3).getCategoryName());
		}
		else
		{
			MainActivity.catFourView.setText("New Category");
		}
		
		if(MainActivity.db.categoryCount() > 4)
		{
			MainActivity.catFiveView.setText(result.get(4).getCategoryName());
		}
		else
		{
			MainActivity.catFiveView.setText("New Category");
		}
		
	}

}
